package com.txunda.zhuohired.aty.user.my;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.ants.theantsgo.util.JSONUtils;
import com.ants.theantsgo.util.L;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.aty.user.find.ShareAty;
import com.txunda.zhuohired.base.BaseAty;
import com.txunda.zhuohired.http.pst.InfoPst;

import java.util.Map;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/9 15:24
 * 功能描述：推广好友
 * 联系方式：jiahuanchen@126.com
 */

public class GeneralizeAty extends BaseAty {


    /**
     * 标题
     */
    @ViewInject(R.id.tv_layout_white_center)
    private TextView tv_layout_white_center;
    @ViewInject(R.id.tv_generalize_tuiguang)
    private TextView tv_generalize_tuiguang;
    @ViewInject(R.id.tv_leiji_money)
    private TextView tv_leiji_money;
    @ViewInject(R.id.tv_generalize_wode)
    private TextView tv_generalize_wode;


    private InfoPst infoPst;
    private String token;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showStatusBar(R.id.layout_white_head);
        tv_layout_white_center.setText("推广好友");
    }

    @Override
    @OnClick({R.id.tv_generalize_deposit, R.id.tv_generalize_share, R.id.tv_generalize_rules})
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_generalize_deposit://去提现
                startActivity(DepositAty.class, null);
                break;
            case R.id.tv_generalize_share://分享
                startActivity(ShareAty.class, null);
                break;
            case R.id.tv_generalize_rules://活动规则

                break;
        }
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.aty_generalize;
    }

    @Override
    protected void initialized() {
        infoPst = new InfoPst(this);
        token = application.getUserInfo().get("data");
    }

    @Override
    protected void requestData() {
        infoPst.extension(token);
    }

    @Override
    public void onComplete(String requestUrl, String jsonStr) {
        super.onComplete(requestUrl, jsonStr);
        if (requestUrl.contains("extension")) {
            L.e("=====extension=====", jsonStr);
            Map<String, String> map = JSONUtils.parseKeyAndValueToMap(jsonStr);
            Map<String, String> data = JSONUtils.parseKeyAndValueToMap(map.get("data"));
            if(map.get("code").equals("1")){
                tv_generalize_tuiguang.setText(data.get("h_money")+"元");
                tv_leiji_money.setText("累计（元）："+data.get("count_money"));
                tv_generalize_wode.setText("为好友发送推广链接，他首次注册下载后您可以获得"+data.get("m_money")+"元作为奖励，邀请越多可获得现金越多");
            }
            if(map.get("code").equals("0")){

            }

        }
    }
}
